package com.example.guiadigital4;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import android.graphics.drawable.Drawable;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class PuntoAPunto extends MapActivity  {
	private MapView map = null;
	
	private MapController mapController;
	private MyLocationOverlay myLocationOverlay;
	
	private MapView mapView;
	protected List<Overlay> mapOverlays;
	
	private void inicializeMap(){
	     mapView = (MapView) findViewById(R.id.mapview);
	        mapView.setBuiltInZoomControls(true);        
	        mapController = mapView.getController();
	        mapController.setZoom(9);  
	        mapController.animateTo(new GeoPoint(0,0));
	        centerMyPosition();
	        
	        
	        mapOverlays = mapView.getOverlays();
	    //    Drawable drawable = getResources().getDrawable(R.drawable.marker);
	        
	 //       OverlayItem overlayItem = new OverlayItem(new GeoPoint(0,0), "titulo", "descripcion");     
	  //      MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable, mapView.getContext(), mapView);
	   //     itemizedoverlay.addOverlay(overlayItem);
	    //    mapOverlays.add(itemizedoverlay);	        
	        
	}
	
	private void centerMyPosition(){
        myLocationOverlay = new MyLocationOverlay(this, mapView);
        mapView.getOverlays().add(myLocationOverlay);
        myLocationOverlay.enableCompass();
        myLocationOverlay.enableMyLocation();
        myLocationOverlay.runOnFirstFix(new Runnable() {
            public void run() {
                mapController.animateTo(myLocationOverlay.getMyLocation());
            }
        });
}
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_punto_apunto);
 
        map = (MapView)findViewById(R.id.mapview);
 
        map.setBuiltInZoomControls(true);
        
        
        inicializeMap();
        
        List<GeoPoint> list = new ArrayList<GeoPoint>();
        list.add(new GeoPoint(40405131,-3713379));
        list.add(new GeoPoint(41407280, 2161620));
        list.add(new GeoPoint(7280, 620));    
        for(int i = 0; i < list.size(); i++){
         if(i>0){
          mapOverlays.add(new LinePathOverlay(list.get(i-1), list.get(i)));
         }

        }
    }
 
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
    
}
